﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="dituxianshi.aspx.cs" Inherits="weba.dituxianshi" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <style type="text/css">

	body {
        height: 480px;
           width: 640px; 
           margin:0px; 
           padding:0px }
	   #container {
           height: 480px;
           width: 640px;
           float: left;
       }
       #form1 {
           height: 480px;
           width: 640px;
           float: left;
       }
       #ztd {
           height: auto;
           width: 150px;
           float: left;
       }  

    </style>
     <script type="text/javascript"
	src="http://webapi.amap.com/maps?v=1.2&key=ab5ae8097e26040fa604012b73e78f03">
</script> 
    <script type="text/javascript" src="Scripts/jquery-1.8.2.min.js"></script>   
<script type="text/javascript">
    var ln;
    var point;
    var mapObj;
    function raa() {

        // x=   WebService.HelloWorld();
        //  alert("adda");
        //  x = ln.getLng();
        //  var y = ln.getlnt();
        alert(x);

    }
    function a() {
        //  weba.wajax.HelloWorld(onresult);
        x = ln.getLng();
        y = ln.getLat();
        weba.wajax.xiougai(x, y, '<%= Request.QueryString["id"] %>', onresult)

    }
    function onresult(result) {
        alert(result);
    }
    function suc(result)
    {
      var  ps = new AMap.LngLat(result[0].lx, result[0].ly);
        // alert(result.length);
        mapObj.setCenter(ps);
        mapObj.setZoom(15);
        for (var i = 0; i < result.length; i++)
        {
            var markera = new AMap.Marker({
                id: result.Id,
                position: new AMap.LngLat(result[i].lx, result[i].ly),
                icon: "http://webapi.amap.com/static/images/marker_sprite.png",
                offset: { x: -8, y: -34 }
            });// 创建点坐标
            mapObj.addOverlays(markera);
        }
    }
    function initialize() {
               pd = '<%= Request.QueryString["pid"] %>'
     mapObj = new AMap.Map("container"); // 创建地图实例
        if (pd == "") {
            point = new AMap.LngLat(121.550331, 29.868038); // 创建点坐标
        }
        else {
        weba.wajax.getbyid(pd, suc);
        point = new AMap.LngLat(121.550331, 29.868038);
            //point = new AMap.LngLat(jd, wd);
            //var markera = new AMap.Marker({
            //    id: "m122",
            //    position: new AMap.LngLat(jd, wd),
            //    icon: "http://webapi.amap.com/static/images/marker_sprite.png",
            //    offset: { x: -8, y: -34 }
            //});// 创建点坐标
            //mapObj.addOverlays(markera);
        }

        //  alert(ln.getLng());

        // var point = new AMap.LngLat(116.404, 39.915); // 创建点坐标
        mapObj.setCenter(point); // 设置地图中心点坐标

        mapObj.bind(mapObj, "click", function (e) {
            ln = e.lnglat;
            var marker = new AMap.Marker({
                id: "m123",
                position: e.lnglat,
                icon: "http://webapi.amap.com/static/images/marker_sprite.png",
                offset: { x: -8, y: -34 }
            });
            //  alert(ln.getLng());
            mapObj.addOverlays(marker);
            mapObj.setCenter(ln);

        });
    }

</script>
   
</head>
<body  onLoad="initialize()">
    <form id="form1" runat="server">
    <div>
         <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True">
            <Services>
                <asp:ServiceReference Path="wajax.asmx"  />
            </Services>
        </asp:ScriptManager>
        </div>
         
   <div id="container"></div> 
    
       
        
    </form>
        
   </body>
</html>
